Skip to content

Conversation

@mudit2812
Copy link
Contributor

@mudit2812 mudit2812 commented Oct 1, 2025

xDSL has a Universe class, which can be used to create entry points that expose custom dialects and passes to tools like xdsl-opt, xdsl-gui. This PR creates the Universe instance and adds it as an entry point to pyproject.toml that xDSL can use.

Notes:

  • There can't be multiple universes containing passes/dialects with the same name. Since we have our own implementation of the transform and stablehlo dialects, I've temporarily skipped their addition to our Universe instance.

[sc-100654]

@mudit2812 mudit2812 added the unified compiler Issues and pull requests related to PennyLane's xDSL python compiler. label Oct 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2025

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@mudit2812 mudit2812 added the do not merge ⚠️ Do not merge the pull request until this label is removed label Oct 2, 2025
@mudit2812 mudit2812 marked this pull request as ready for review October 3, 2025 20:46
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.42%. Comparing base (ee6db4a) to head (60e6e3a).
⚠️ Report is 76 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8372   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files         587      587           
  Lines       61547    61547           
=======================================
  Hits        61196    61196           
  Misses        351      351           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@mehrdad2m mehrdad2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! 🥳

Copy link
Contributor

@andrijapau andrijapau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - thanks for walking me through it.

try:
from xdsl.passes import ModulePass
from xdsl.universe import Universe
except (ImportError, ModuleNotFoundError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except (ImportError, ModuleNotFoundError):
except ModuleNotFoundError:

Can we just keep this ModuleNotFoundError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModuleNotFoundError is for when a package is not installed, but ImportError is for when a package is installed from you're trying to import something from it that doesn't exist. This is a way to future proof the file, so that if xDSL gets reorganized, we don't see ImportErrors. I'd rather just leave it as is.

@mudit2812
Copy link
Contributor Author

Tried building wheels in a fresh environment without jax or xdsl installed. The wheels built fine, and pennylane can be imported without any issues. An error gets raised if I try to load the plugin:

>>> import pennylane as qml
>>> from importlib.metadata import entry_points
>>> plugins = entry_points(group="xdsl.universe")
>>> plugin = None
>>> for p in plugins:
...     if p.name == "pennylane-xdsl-universe:
...         plugin = p
...         break
...
>>> plugin.load()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mudit.pandey/.pyenv/versions/3.12.11/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mudit.pandey/.pyenv/versions/3.12.11/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/mudit.pandey/repos/pennylane/pennylane/compiler/python_compiler/__init__.py", line 16, in <module>
    from .compiler import Compiler
  File "/Users/mudit.pandey/repos/pennylane/pennylane/compiler/python_compiler/compiler.py", line 19, in <module>
    from jax._src.interpreters import mlir
ModuleNotFoundError: No module named 'jax'

Had a discussion with Lee, and the conclusion is that raising an error when trying to load the plugin without the correct dependencies installed (jax and xdsl) is fine, but a better error message should be used. I will hold off on merging for now, and we can resolve this if it becomes a blocker, which it isn't right now.

@mudit2812
Copy link
Contributor Author

Closing in favour of PennyLaneAI/catalyst#2208

@mudit2812 mudit2812 closed this Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge ⚠️ Do not merge the pull request until this label is removed unified compiler Issues and pull requests related to PennyLane's xDSL python compiler.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants